package com.example.questionsystem.modules.qu.common;

import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

@Component
public class DataDirectoryInitializer implements CommandLineRunner {

    @Override
    public void run(String... args) throws Exception {
        // 定义数据目录路径（与 JAR/EXE 同级）
        Path dataDir = Paths.get("data");
        
        // 创建目录（如果不存在）
        if (!Files.exists(dataDir)) {
            Files.createDirectories(dataDir);
            System.out.println("Created data directory: " + dataDir.toAbsolutePath());
        }
    }
}